package cn.itcast.controller;

import cn.itcast.pojo.User;
import cn.itcast.service.UserService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @program: springbootdemo
 * @description: 测试业务controller
 * @author: wxk
 * @create: 2020-12-21 19:45
 **/
@RestController
@RequestMapping("user")
@Slf4j
@Api(tags = "测试接口")
public class HelloController {


    @Autowired
    private UserService userService;


    /**
     * 数据源1的数据
     * @return
     *@author wxk
     */
    @GetMapping("/person/{Id}")
    public ResponseEntity<List<Map<String, Object>>> queryFirstData(@PathVariable("Id") Long Id){
        return ResponseEntity.ok(userService.queryFirstData(Id));
    }

    /**
     * 数据源2的数据
     * @param Id
     * @return
     *@author wxk
     */
    @GetMapping("/user/{Id}")
    public ResponseEntity<User> querySecondData(@PathVariable("Id") Long Id){
        return ResponseEntity.ok(userService.querySecondData(Id));
    }

}
